package com.chinastock.communication;

import com.alibaba.fastjson.annotation.JSONField;

/**
 * 	分页信息
 * @author chenyouguang
 * 2018年3月30日12:36:47
 */
public class BasePageInfo{
	/** 查询页 */
	@JSONField(name = "PageNum")
	private int pageNum;

	/** 每页查询大小 */
	@JSONField(name = "PageSize")
	private int pageSize;

	/** 总记录数 */
	@JSONField(name = "Total")
	private long total;

	/** 排序 */
	@JSONField(name = "OrderBy")
	private String orderBy;

	/** 总页数 */
	@JSONField(name = "Pages")
	private int pages;

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public long getTotal() {
		return total;
	}

	public void setTotal(long total) {
		this.total = total;
	}

	public int getPages() {
		return pages;
	}

	public void setPages(int pages) {
		this.pages = pages;
	}

	public String getOrderBy() {
		return orderBy;
	}

	public void setOrderBy(String orderBy) {
		this.orderBy = orderBy;
	}
	
	
	/**
	 * 	查询记录数量时，设置分页数据
	 * @param total 总条数
	 * @return 返回当前对象
	 */
	public BasePageInfo setPageInfo(int total){
		this.total = total;
		this.pages = (int)(this.total+(this.pageSize-1))/this.pageSize;
		return this;
	}

	@Override
	public String toString() {
		return "BasePageInfo [pageNum=" + pageNum + ", pageSize=" + pageSize + ", total=" + total + ", orderBy="
				+ orderBy + ", pages=" + pages + "]";
	}

	
}
